/*   1:    */ package com.atomikos.datasource.xa.jca;
/*   2:    */ 
/*   3:    */ import com.atomikos.datasource.xa.XATransactionalResource;
/*   4:    */ import com.atomikos.datasource.xa.XidFactory;
/*   5:    */ import java.util.Stack;
/*   6:    */ import javax.resource.spi.ManagedConnection;
/*   7:    */ import javax.resource.spi.ManagedConnectionFactory;
/*   8:    */ import javax.transaction.xa.XAResource;
/*   9:    */ 
/*  10:    */ public class JcaTransactionalResource
/*  11:    */   extends XATransactionalResource
/*  12:    */ {
/*  13:    */   private ManagedConnectionFactory mcf;
/*  14:    */   private ManagedConnection connection;
/*  15:    */   
/*  16:    */   public JcaTransactionalResource(String servername, ManagedConnectionFactory mcf)
/*  17:    */   {
/*  18: 59 */     super(servername);
/*  19: 60 */     this.mcf = mcf;
/*  20:    */   }
/*  21:    */   
/*  22:    */   public JcaTransactionalResource(String servername, ManagedConnectionFactory mcf, XidFactory xidFactory)
/*  23:    */   {
/*  24: 67 */     super(servername, xidFactory);
/*  25: 68 */     this.mcf = mcf;
/*  26:    */   }
/*  27:    */   
/*  28:    */   public boolean usesXAResource(XAResource xares)
/*  29:    */   {
/*  30: 79 */     return false;
/*  31:    */   }
/*  32:    */   
/*  33:    */   protected XAResource refreshXAConnection()
/*  34:    */     throws com.atomikos.datasource.ResourceException
/*  35:    */   {
/*  36: 87 */     printMsg("refreshXAConnection() for resource: " + getName(), 2);
/*  37:    */     
/*  38: 89 */     XAResource ret = null;
/*  39: 90 */     if (this.connection != null) {
/*  40:    */       try
/*  41:    */       {
/*  42: 92 */         this.connection.destroy();
/*  43:    */       }
/*  44:    */       catch (Exception normal) {}
/*  45:    */     }
/*  46:    */     try
/*  47:    */     {
/*  48:101 */       printMsg("about to block for new connection...", 2);
/*  49:    */       
/*  50:103 */       this.connection = this.mcf.createManagedConnection(null, null);
/*  51:    */     }
/*  52:    */     catch (javax.resource.ResourceException e)
/*  53:    */     {
/*  54:108 */       this.connection = null;
/*  55:    */     }
/*  56:    */     finally
/*  57:    */     {
/*  58:111 */       printMsg("blocking done.", 2);
/*  59:    */     }
/*  60:    */     try
/*  61:    */     {
/*  62:115 */       if (this.connection != null) {
/*  63:116 */         ret = this.connection.getXAResource();
/*  64:    */       }
/*  65:    */     }
/*  66:    */     catch (javax.resource.ResourceException e)
/*  67:    */     {
/*  68:118 */       printMsg("error getting XAResource: " + e.getMessage(), 1);
/*  69:    */       
/*  70:120 */       Stack errors = new Stack();
/*  71:121 */       errors.push(e);
/*  72:122 */       throw new com.atomikos.datasource.ResourceException("Error in getting XA resource", errors);
/*  73:    */     }
/*  74:125 */     printMsg("refreshXAConnection() done.", 2);
/*  75:    */     
/*  76:    */ 
/*  77:    */ 
/*  78:129 */     return ret;
/*  79:    */   }
/*  80:    */   
/*  81:    */   public void close()
/*  82:    */     throws com.atomikos.datasource.ResourceException
/*  83:    */   {
/*  84:139 */     super.close();
/*  85:    */     try
/*  86:    */     {
/*  87:141 */       if (this.connection != null) {
/*  88:142 */         this.connection.destroy();
/*  89:    */       }
/*  90:    */     }
/*  91:    */     catch (Exception err) {}
/*  92:    */   }
/*  93:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.datasource.xa.jca.JcaTransactionalResource
 * JD-Core Version:    0.7.0.1
 */